package cs575.wido.model;

import cs575.wido.UserSession;
import cs575.wido.WebServiceFactory;
import java.util.List;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

public class GroupModel extends AbstractTableModel {
	private final String[] columnNames = {"Name", "Description"};
	//private final List<cs575.client.GroupMember> groups;
        private final List<String[]> groups;

	public GroupModel() {
		cs575.client.WiDo wido = WebServiceFactory.getPort();
		cs575.client.Session session = UserSession.getInstance().getSession();
		int userid = session.getUserId();
		//groups = wido.getGroups(session, userid);
                groups = new Vector<String[]>();
                groups.add(new String[]{"Group1","group description"});
                groups.add(new String[]{"Group2","group description"});
                groups.add(new String[]{"Group3","group description"});
                groups.add(new String[]{"Group4","group description"});
	}
	
	@Override
	public int getColumnCount() {
		return this.columnNames.length;
	}
	
	public String getColumnName(int column) {
		return columnNames[column];
	}
	
	@Override
	public int getRowCount() {
            return this.groups.size();
            /*
		if (groups == null) {
			return 0;
		}
		else {
			return groups.size();
		}
             * 
             */
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
            /*
		if (groups == null) {
			return "";
		}
		if (arg1 == 0) {
			return groups.get(arg0).getGroupEx().getGroupName();
		}
		else {
			return groups.get(arg0).getGroupEx().getGroupDescription();
		}
             * 
             */
            return this.groups.get(arg0)[arg1];
	}
	
        /*
	public cs575.client.GroupEx getGroupAt(int index) {
		return groups.get(index).getGroupEx();
	}
         * 
         */
        
        public String[] getGroup(int index) {
            return this.groups.get(index);
        }
}
